Confirming which availability zone is used for the RDS DB instance when changing from Multi-AZ to Single-AZ configuration

Confirming which availability zone is used for the RDS DB instance when changing from Multi-AZ to Single-AZ configuration

Clock Icon2018.11.04

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

In this post, we will explain how to determine which availability zones is used for the RDS DB instance when changing from Multi-AZ configuration to Single-AZ configuration.

Overview

We will use RDS for MySQL and we will check what happens to AZ with the following four patterns.

  • When changing from Multi-AZ configuration to Single-AZ configuration
  • When changing from Single-AZ configuration to Multi-AZ configuration
  • When changing from Multi-AZ configuration to Single-AZ configuration and change instance class.
  • When changing from Single-AZ configuration to Multi-AZ configuration and change instance class.

When changing from Multi-AZ configuration to Single-AZ configuration (No failover)

Current DB instance information

Currently MultiAZ is true and us-west-2a is primary.

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": true,
  "AvailabilityZone": "us-west-2a"
}

Changing to Single-AZ configuration

Change from Multi-AZ to Single-AZ using the --no-multi-az option.

$ aws rds modify-db-instance \
      --db-instance-identifier test-db \
      --no-multi-az \
      --apply-immediately

DB instance information after change

After changing to the Single-AZ configuration, we can confirm that the DB instance is in us-west-2a which was Primary in the Multi-AZ configuration.

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": false,
  "AvailabilityZone": "us-west-2a"
}

Viewing events

$ aws rds describe-events --source-identifier test-db --source-type db-instance | jq -c '.Events[] | {Date, Message}'
{"Date":"2018-09-03T16:56:44.351Z","Message":"Applying modification to convert to a standard (Single-AZ) DB Instance"}
{"Date":"2018-09-03T17:00:53.925Z","Message":"Finished applying modification to convert to a standard (Single-AZ) DB Instance"}

When changing from Single-AZ configuration to Multi-AZ configuration

We switched back from the Single-AZ configuration to the Multi-AZ configuration, but in this case there was no change in AZ.

Changing to Multi-AZ configuration

Change from Single-AZ to Multi-AZ using the --multi-az option.

aws rds modify-db-instance \
      --db-instance-identifier test-db \
      --multi-az \
      --apply-immediately

DB instance information after change

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": true,
  "AvailabilityZone": "us-west-2a"
}

Viewing events

$ aws rds describe-events --source-identifier test-db --source-type db-instance | jq -c '.Events[] | {Date, Message}'
{"Date":"2018-09-03T17:09:19.244Z","Message":"Applying modification to convert to a Multi-AZ DB Instance"}
{"Date":"2018-09-03T17:17:41.706Z","Message":"Finished applying modification to convert to a Multi-AZ DB Instance"}

When changing from Multi-AZ configuration to Single-AZ configuration and changing instance class (with failover)

Next, let's change from the Multi-AZ configuration to the Single-AZ configuration together with a change that causes failover. This time, we are changing the instance class causing the failover to occur.

Current DB instance information

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": true,
  "AvailabilityZone": "us-west-2a"
}

Changing to Single-AZ configuration

Changing the instance class using the --db-instance-class option and change from Multi-AZ to Single-AZ using the --no-multi-az option.

aws rds modify-db-instance \
      --db-instance-identifier test-db \
      --no-multi-az \
      --db-instance-class db.t2.small \
      --apply-immediately

DB instance information after change

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": false,
  "AvailabilityZone": "us-west-2b"
}

The AZ in which the DB instance runs in has changed. We will check the events.

Viewing events

We can see that Multi-AZ instance failover has occurred when changing the instance class, after which it seems that the AZ has changed to Single-AZ.

$ aws rds describe-events --source-identifier test-db --source-type db-instance | jq -c '.Events[] | {Date, Message}'
{"Date":"2018-09-03T17:25:36.553Z","Message":"Applying modification to database instance class"}
{"Date":"2018-09-03T17:29:50.993Z","Message":"DB instance shutdown"}
{"Date":"2018-09-03T17:30:53.738Z","Message":"Multi-AZ instance failover started"}
{"Date":"2018-09-03T17:31:03.340Z","Message":"DB instance restarted"}
{"Date":"2018-09-03T17:31:33.748Z","Message":"Multi-AZ instance failover completed"}
{"Date":"2018-09-03T17:40:46.647Z","Message":"Finished applying modification to DB instance class"}
{"Date":"2018-09-03T17:40:51.886Z","Message":"Applying modification to convert to a standard (Single-AZ) DB Instance"}
{"Date":"2018-09-03T17:45:01.242Z","Message":"Finished applying modification to convert to a standard (Single-AZ) DB Instance"}

Finally, let's try to change the AZ configuration about from Single-AZ configuration to Multi-AZ configuration and changing the instance class.

When changing from Single-AZ configuration to Multi-AZ configuration and change instance class

Let me get to the point first. When we change the instance class and the AZ configuration from Single-AZ configuration to Multi-AZ configuration at the same time, there is no change in AZ.

Changing to Multi-AZ configuration

Change from Single-AZ to Multi-AZ using the --multi-az option and changing the instance class using the --db-instance-class option

$ aws rds modify-db-instance \
      --db-instance-identifier test-db \
      --no-multi-az \
      --db-instance-class db.t2.micro \
      --apply-immediately

DB instance information after change

$ aws rds describe-db-instances --db-instance-identifier test-db | jq '.DBInstances[] | {MultiAZ, AvailabilityZone}'
{
  "MultiAZ": false,
  "AvailabilityZone": "us-west-2b"
}

Viewing events

$ aws rds describe-events --source-identifier test-db --source-type db-instance | jq -c '.Events[] | {Date, Message}'
{"Date":"2018-09-03T17:59:38.155Z","Message":"Applying modification to database instance class"}
{"Date":"2018-09-03T18:01:04.717Z","Message":"DB instance shutdown"}
{"Date":"2018-09-03T18:04:30.623Z","Message":"DB instance restarted"}
{"Date":"2018-09-03T18:05:19.334Z","Message":"Finished applying modification to DB instance class"}
{"Date":"2018-09-03T18:05:25.811Z","Message":"DB instance shutdown"}
{"Date":"2018-09-03T18:05:35.110Z","Message":"DB instance restarted"}

Conclusion

We introduced what happens to the Availability Zone where the DB Instance runs in when changing between Single-AZ and Multi-AZ RDS configurations.

Please see the table below for the results.

Configuration change content Changing the Primary AZ of the DB Instance
From Multi-AZ configuration to Single-AZ configuration(No failover) No change
From Multi-AZ configuration to Single-AZ configuration(With failover) With change
From Single-AZ configuration to Multi-AZ configuration No change

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.